package com.xhwl.logistics.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

@Getter
@AllArgsConstructor
public enum VehicleParkingLotFindCarHandlerEnum {

    VEHICLE_PARKINGLOT_NOTHING(-1, "vehicleParkingLotNothingFindCarHandlerImpl"),
    VEHICLE_PARKINGLOT_KETOP(3, "vehicleParkingLotKeTopFindCarHandlerImpl");

    private final Integer productId;

    private final String findCarHandlerName;

    private static final Map<Integer, VehicleParkingLotFindCarHandlerEnum> map;
    static {
        map = new HashMap<>();
        for (VehicleParkingLotFindCarHandlerEnum vehicleParkingLotFindCarHandlerEnum : VehicleParkingLotFindCarHandlerEnum.values()) {
            map.put(vehicleParkingLotFindCarHandlerEnum.getProductId(), vehicleParkingLotFindCarHandlerEnum);
        }
    }

    public static VehicleParkingLotFindCarHandlerEnum toVehicleParkingLotFindCarHandlerEnum(Integer productId) {
        return Optional.ofNullable(map.get(productId)).orElse(VEHICLE_PARKINGLOT_NOTHING);
    }

}
